#!/usr/bin/perl -w
#   Written by Jimmy Saw - 10-11-2007
#   This program takes a Genbank file and extract protein sequence fastas
#   You have to redirect output to a file

use Bio::SeqIO;

my $seqio_obj = Bio::SeqIO->new (-file => $ARGV[0], -format => 'genbank');
my $seq_obj = $seqio_obj->next_seq;

for my $feat_obj ($seq_obj->get_SeqFeatures){
    if ($feat_obj->primary_tag eq "CDS"){

        if ($feat_obj->has_tag('locus_tag')){
            for my $value ($feat_obj->get_tag_values('locus_tag')){
                print $value, "\t";
            }
        }

        if ($feat_obj->has_tag('product')){
            for my $value ($feat_obj->get_tag_values('product')){
                print $value, "\t";
            }
        }

        if ($feat_obj->has_tag('gene')){
            for my $value ($feat_obj->get_tag_values('gene')){
                print $value;
            }
        }
        print "\n";
    }
}
